Get the number of days of a given month and yearΒΆ

calendar.monthrange(year, month)

Get the number of days of a given month and year.
import calendar

year = 2016
month = 2

print(calendar.monthrange(year, month))

Output:

(0, 29)